home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / graphs / graphed-.1 / graphed- / usr / local / graphed / include / sgraph / graphed_structures.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-10  |  9.5 KB  |  328 lines

  1. /* (C) Universitaet Passau 1986-1994 */
  2. /* Sgraph Source, 1988-1994 by Michael Himsolt */
  3.  
  4. #ifndef GRAPHED_STRUCTURE_H
  5. #define GRAPHED_STRUCTURE_H
  6.  
  7. #include <xview/rect.h>
  8.  
  9. #ifndef EXTERN_LINK_MODULE
  10. #include <graph.h>
  11.  
  12. /* define virtual access to some of GraphEd's data structures    */
  13.  
  14. typedef    Graph        Graphed_graph;
  15. typedef    Node        Graphed_node;
  16. typedef    Edge        Graphed_edge;
  17. typedef    Group        Graphed_group;
  18.  
  19. #else
  20.  
  21. typedef    char *        Graphed_graph;
  22. typedef    char *        Graphed_node;
  23. typedef    char *        Graphed_edge;
  24. typedef    char *        Graphed_group;
  25.  
  26. typedef enum {
  27.         NEW_EDGE,
  28.         OLD_EDGE_REAL_POINT,
  29.         OLD_EDGE_IMAGINARY_POINT,
  30. } Edge_drag_info;
  31.  
  32. typedef enum {
  33.         MOVE_NODE,
  34.         SCALE_NODE_MIDDLE,
  35.         SCALE_NODE_UPPER_LEFT,
  36.         SCALE_NODE_UPPER_RIGHT,
  37.         SCALE_NODE_LOWER_LEFT,
  38.         SCALE_NODE_LOWER_RIGHT
  39. } Node_drag_info;
  40.  
  41. typedef enum    {
  42.  
  43.         /* Dummy for end of list        */
  44.         SET_ATTRIBUTE_END = 0,
  45.  
  46.         /* Node attributes              */
  47.         NODE_POSITION = 1,
  48.         NODE_SIZE  = NODE_POSITION << 1,
  49.         NODE_TYPE  = NODE_SIZE     << 1,
  50.         NODE_NEI   = NODE_TYPE     << 1,
  51.         NODE_NLP   = NODE_NEI      << 1,
  52.         NODE_LABEL = NODE_NLP      << 1,
  53.         NODE_FONT  = NODE_LABEL    << 1,
  54.         NODE_LABEL_VISIBILITY = NODE_FONT << 1,
  55.         NODE_COLOR = NODE_LABEL_VISIBILITY << 1,
  56.  
  57.         /* Edge attributes              */
  58.         EDGE_LINE = NODE_COLOR << 1,
  59.         EDGE_TYPE = EDGE_LINE << 1,
  60.         EDGE_ARROW_LENGTH = EDGE_TYPE << 1,
  61.         EDGE_ARROW_ANGLE  = EDGE_ARROW_LENGTH << 1,
  62.         EDGE_LABEL = EDGE_ARROW_ANGLE << 1,
  63.         EDGE_FONT  = EDGE_LABEL << 1,
  64.         EDGE_LABEL_VISIBILITY = EDGE_FONT << 1,
  65.         EDGE_COLOR = EDGE_LABEL_VISIBILITY << 1,
  66.  
  67.         /* Misc */
  68.         EDGE_INSERT = EDGE_COLOR + 1,
  69.         EDGE_DELETE = EDGE_INSERT + 1,
  70.  
  71.         MOVE   = EDGE_DELETE + 1,
  72.         RESIZE = MOVE + 1,
  73.  
  74.         /* Specialities                 */
  75.         ONLY_SET   = RESIZE + 1,
  76.         RESTORE_IT = ONLY_SET + 1,
  77.  
  78.         /* Sgraph goodies               */
  79.         NODE_WIDTH  = RESTORE_IT + 1,
  80.         NODE_HEIGHT = NODE_WIDTH + 1,
  81.         NODE_X      = NODE_HEIGHT + 1,
  82.         NODE_Y      = NODE_X + 1,
  83.  
  84. }
  85.         Set_attribute;
  86.  
  87.  
  88. typedef    enum    {
  89.     UEV_CLICK,
  90.     UEV_DOUBLE_CLICK,
  91.     UEV_DRAG_NODE,
  92.     UEV_DRAG_EDGE,
  93.     UEV_DRAG_GROUP,
  94.     UEV_DRAG_BOX,
  95.     NUMBER_OF_UEV_FUNCTIONS
  96. }
  97.     User_event_functions_type;    
  98.  
  99. typedef    enum    {
  100.         UEV_START,
  101.         UEV_DRAG,
  102.         UEV_INTERMEDIATE_STOP,
  103.         UEV_FINISH,
  104.         UEV_ERROR
  105. }
  106.     User_event_functions_state;    
  107.  
  108. extern void graphed_main(int argc, char **argv);
  109. extern  void    message       (char *format, ...);
  110. extern  void    warning       (char *format, ...);
  111. extern  void    error         (char *format, ...);
  112. extern  void    fatal_error   (char *format, ...);
  113. extern  void    add_to_file_menue (char *string, void (*proc)());
  114. extern  void    add_to_user_menue (char *string, void (*proc)());
  115. extern  void    add_to_layout_menue (char *string, void (*proc)());
  116. extern  void    add_to_tools_menue (char *string, void (*proc)());
  117. extern  void    add_to_goodies_menue (char *string, void (*proc)());
  118. extern  void    add_to_extra_menue (char *string, void (*proc)());
  119.  
  120. #endif
  121.  
  122. extern    Graphed_graph    graphed_graph (Sgraph sgraph);
  123. extern    Graphed_node    graphed_node  (Snode snode);
  124. extern    Graphed_edge    graphed_edge  (Sedge sedge);
  125.  
  126. extern    void        graph_set (Graphed_graph graph, ...);
  127. extern    void        node_set  (Graphed_node node, Set_attribute attr, ...);
  128. extern    void        edge_set  (Graphed_edge edge, Set_attribute attr, ...);
  129. extern    void        group_set (Graphed_group group, ...);
  130.  
  131. extern    char        *node_get  ();
  132. extern    char        *edge_get  ();
  133.  
  134. extern    Graphed_graph    create_graphed_graph_from_sgraph ();
  135. extern    Graphed_node    create_graphed_node_from_snode   ();
  136. extern    Graphed_edge    create_graphed_edge_from_sedge   ();
  137. extern    Graphed_group    create_graphed_group_from_slist  ();
  138.  
  139. extern    void    add_string_entry_to_menu ();
  140. extern    void    add_image_entry_to_menu ();
  141. extern    void    add_entry_to_menu ();
  142. extern    void    add_menu_to_menu ();
  143.  
  144. extern    void    add_to_tools_menu ();
  145. extern    void    add_to_layout_menu ();
  146. extern    void    add_to_goodies_menu ();
  147. extern  void    add_to_user_menu ();
  148.  
  149. extern    void    add_menu_to_tools_menu ();
  150. extern    void    add_menu_to_layout_menu ();
  151. extern    void    add_menu_to_goodies_menu ();
  152. extern  void    add_menu_to_user_menu ();
  153.  
  154. extern    int    wac_buffer;
  155.  
  156. extern    void    free_group ();
  157.  
  158. extern    int    find_nodetype ();
  159. extern    int    find_edgetype ();
  160. extern    int    find_font ();
  161.  
  162. #ifndef EXTERN_LINK_MODULE
  163. #include <graphed/user.h>
  164. #else
  165. #ifndef USER_HEADER
  166. #include "dispatch_commands.h"
  167. extern  char    *dispatch_user_action ();
  168. #endif
  169.  
  170. typedef enum {
  171.         NODELABEL_MIDDLE,
  172.         NODELABEL_UPPERLEFT,
  173.         NODELABEL_UPPERRIGHT,
  174.         NODELABEL_LOWERLEFT,
  175.         NODELABEL_LOWERRIGHT,
  176.  
  177.         NUMBER_OF_NODELABEL_PLACEMENTS          /* Dummy                */
  178.         }
  179.         Nodelabel_placement;
  180.  
  181.  
  182. typedef enum {
  183.         NO_NODE_EDGE_INTERFACE,                 /* "none"               */
  184.         TO_BORDER_OF_BOUNDING_BOX,              /* "middle"             */
  185.         TO_CORNER_OF_BOUNDING_BOX,              /* "corner"             */
  186.         CLIPPED_TO_MIDDLE_OF_NODE,              /* "clipped"            */
  187.         SPECIAL_NODE_EDGE_INTERFACE,            /* "special"            */
  188.  
  189.         NUMBER_OF_NODE_EDGE_INTERFACES          /* Dummy                */
  190.         }
  191.         Node_edge_interface;
  192.  
  193.  
  194. typedef struct  edgeline
  195. {
  196.         coord           x,y;            /* Koordinaten                  */
  197.         struct edgeline *pre,           /* vorheriges Stueck            */
  198.                         *suc;           /* naehstes   Stueck            */
  199.         Rect            box;            /* Rechteck, in dem die         */
  200.                                         /* Edgeline (mit ->suc) liegt   */
  201. }
  202.         *Edgeline;
  203.  
  204. #define edgeline_x(el)   ((el)->x)
  205. #define edgeline_y(el)   ((el)->y)
  206. #define edgeline_pre(el) ((el)->pre)
  207. #define edgeline_suc(el) ((el)->suc)
  208. #define is_single_edgeline(el) \
  209.         (((el) != (Edgeline)NULL) && ((el)->suc->suc == (el)))
  210.          
  211. extern  Edgeline        new_edgeline         ();
  212. extern  Edgeline        add_to_edgeline      ();
  213. extern  Edgeline        remove_from_edgeline ();
  214. extern  void            set_edgeline_xy      ();
  215. extern  void            free_edgeline        ();
  216. extern  Edgeline        copy_edgeline        ();
  217.  
  218. #define for_edgeline(el_head,el) \
  219.         { if (((el) = (el_head)) != (Edgeline)NULL) do {
  220. #define end_for_edgeline(el_head,el) \
  221.         } while (((el) = (el)->suc) != (el_head)); }
  222.  
  223.  
  224. /*      template structure for node attributes  */
  225.  
  226. typedef struct  node_attributes {
  227.  
  228.         unsigned int            set;
  229.  
  230.         int                     type_index, font_index;
  231.         int                     label_visibility;
  232.         Node_edge_interface     node_edge_interface;
  233.         Nodelabel_placement     nodelabel_placement;
  234.         int                     color;
  235.         int                     x,y;            /* not always needed    */
  236.         int                     width, height;  /* not always needed    */
  237.         char                    *label;         /* not always needed    */
  238. }
  239.         Node_attributes;
  240.  
  241. extern  Node_attributes get_node_attributes ();
  242.  
  243.  
  244.  
  245. /*      template structure for edge attributes  */
  246.  
  247. typedef struct  edge_attributes {
  248.  
  249.         unsigned int            set;
  250.  
  251.         int                     type_index, font_index;
  252.         int                     label_visibility;
  253.         float                   arrow_angle;
  254.         int                     arrow_length;
  255.         int                     color;
  256.         Edgeline                line;   /* not always needed    */
  257.         char                    *label; /* not always needed    */
  258. }
  259.         Edge_attributes;
  260.  
  261. extern  Edge_attributes get_edge_attributes ();
  262.  
  263.  
  264. /*      Macros to set values from a Node_attributes/Edge_attributes     */
  265. /*      structure.                                                      */
  266. /*      POSITIONS and LABELS are NOT set !                              */
  267.  
  268. #define SET_NODE_ATTRIBUTES(attr) \
  269.         NODE_SIZE,              (attr).width, (attr).height,    \
  270.         NODE_FONT,              (attr).font_index,              \
  271.         NODE_TYPE,              (attr).type_index,              \
  272.         NODE_NEI,               (attr).node_edge_interface,     \
  273.         NODE_NLP,               (attr).nodelabel_placement,     \
  274.         NODE_LABEL_VISIBILITY,  (attr).label_visibility,        \
  275.         NODE_COLOR,             (attr).color
  276.  
  277. #define SET_EDGE_ATTRIBUTES(attr) \
  278.         EDGE_TYPE,              (attr).type_index,              \
  279.         EDGE_FONT,              (attr).font_index,              \
  280.         EDGE_ARROW_LENGTH,      (attr).arrow_length,            \
  281.         EDGE_ARROW_ANGLE,       (attr).arrow_angle,             \
  282.         EDGE_LABEL_VISIBILITY,  (attr).label_visibility,        \
  283.         EDGE_COLOR,             (attr).color
  284.  
  285.  
  286. typedef enum    {
  287.         UEV_CONSUMED,
  288. /*    UEV_NOT_CONSUMED, */
  289.         UEV_VETO
  290. }
  291.         User_event_functions_result;
  292. #endif
  293.  
  294. extern void force_repainting ();
  295. extern void lock_user_interface ();
  296. extern void unlock_user_interface ();
  297. extern int test_user_interface_locked ();
  298.  
  299. extern    void    set_user_event_func();
  300. extern    void    remove_user_event_func();
  301.  
  302. extern    void    buffer_set_filename();
  303. extern    char    *buffer_get_filename();
  304. extern    int    buffer_is_unused();
  305. extern    int    find_buffer_by_name();
  306. extern    int    get_buffer_by_name();
  307.  
  308. #ifndef GRAPHED_PICKLIST_DEFINED
  309. #ifndef EXTERN_LINK_MODULE
  310. #include <graphed/find.h>
  311. #else
  312. typedef char *Picklist;
  313.  
  314. typedef    enum {
  315.     NODE_PICKED,
  316.     EDGE_PICKED,
  317.     GROUP_PICKED
  318. }
  319.     What_is_picked;
  320.  
  321. extern    Picklist new_picklist(What_is_picked what, ...);
  322. extern    Picklist add_to_picklist(Picklist pl, What_is_picked what, ...);
  323. extern    void free_picklist();
  324. #endif
  325. #endif
  326.  
  327. #endif
  328.